<%--
  Created by IntelliJ IDEA.
  User: 20275
  Date: 2023/11/18
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@include file="/pages/common/head.jsp"%>

<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">添加寝室信息</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    寝室管理 >> 添加寝室信息
                </div>
                <div class="panel-body">
                    <form role="form" action="${pageContext.request.contextPath }/chamber/addInfo" method="post" onsubmit="return validateForm()">

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="form-group">
                                    <label>寝室楼</label>
                                    <select class="form-control" id="chamber_floor_select" name="chamberFloorId">
                                        <option value="0">----请选择寝室楼----</option>
                                        <c:forEach items="${chamberfloorinfos}" var="info">
                                            <option value="${info.chamberFloorId}">${info.chamberFloorName}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>寝室号</label>
                                    <input class="form-control" name="chamberHotelNumber" required>
                                </div>
                                <div class="form-group">
                                    <label>楼层</label>
                                    <select class="form-control" id="chamber_floor_number_select" name="chamberFloor">
                                        <option value="0">----请选择寝室楼层----</option>
                                        <c:forEach begin="1" end="6" var="i">
                                            <option value="${i}">${i}层</option>
                                        </c:forEach>
                                    </select>
                                </div>

                            </div>
                            <div class="col-lg-6">
                                <div class="form-group">
                                    <label>寝室类型</label>
                                    <select class="form-control" id="chamber_type_select" name="chamberTypeId">
                                        <option value="0">----请选择寝室类型----</option>
                                        <c:forEach items="${chambertypeinfos}" var="info">
                                            <option value="${info.chamberTypeId}">${info.chamberTypeName}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>寝室最大人数</label>
                                    <select class="form-control" id="chamber_bed_select" name="chamberBed">
                                        <option value="0">----请选择寝室最大人数----</option>
                                        <c:forEach begin="1" end="6" var="i">
                                            <option value="${i}">${i}人</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <input type="submit" class="btn btn-primary" value="添加">
                                <input type="reset" class="btn btn-warning" value="重置">
                            </div>
                        </div>

                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<c:if test="${message != null}">
    <script>
        alert("${message}")
    </script>
    <% session.removeAttribute("message"); %>
</c:if>
<script>
    function validateForm() {
        var chamber_floor_select = $('#chamber_floor_select').val();
        var chamber_floor_number_select = $('#chamber_floor_number_select').val();
        var chamber_type_select = $('#chamber_type_select').val();
        var chamber_bed_select = $('#chamber_bed_select').val();

        if(chamber_floor_select != 0 && chamber_floor_number_select != 0
            && chamber_type_select != 0 && chamber_bed_select != 0){
            return true
        }else{
            alert("请将信息填充完整！")
            return false
        }
    }
</script>

<%@include file="/pages/common/foot.jsp" %>
